#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int a, b, d;
	int c = 2;
	scanf("%d %d", &a, &b);
	while (c <= a && c <= b)
	{
		if (a % c == 0 && b % c == 0)
		{
			d = c;
		}
		c++;
	}
	printf("%d", d);
	return 0;
}